package com.woniuxy.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniuxy.entity.PickGoods;
import com.woniuxy.service.PickGoodsSevice;
import com.woniuxy.utils.Result;

@Controller
@RequestMapping("/pickgoods")
public class PickGoodsController {
	@Autowired
	private PickGoodsSevice pickGoodsSevice;
	@RequiresPermissions("manager:find")
	@RequestMapping("/all")
	@ResponseBody
	public Result<List<PickGoods>> all(){
		Result<List<PickGoods>> result = new Result<>();
		result.setData(pickGoodsSevice.all());
		return result;
		
	}
	
	@RequestMapping("/add")
	@ResponseBody
	public Result<List<PickGoods>> addPickGoods(PickGoods pickGoods){
		Result<List<PickGoods>> result = new Result<>();
		if(pickGoodsSevice.addPickGoods(pickGoods)==1){
			result.setStatus(Result.SUCCESS);
			result.setMessage("ok");
			return result;
		}else{
			result.setStatus(Result.ERROR);
			result.setMessage("no");
			return result;
		}
		
	}
	@RequestMapping("/delete")
	@ResponseBody
	public Result<List<PickGoods>> deletePickGoods(int cgid){
		Result<List<PickGoods>> result = new Result<>();
		if(pickGoodsSevice.deletePickGoods(cgid)==1){
			result.setStatus(Result.SUCCESS);
			result.setMessage("ok");
			
		}else{
			result.setStatus(Result.ERROR);
			result.setMessage("no");
			
		}
		return  result;
	}
	
}
